package com.zoespeer.food_delivery_comment_api.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zoespeer.food_delivery_comment_api.common.ApiResponse;
import com.zoespeer.food_delivery_comment_api.entity.Restaurant;
import com.zoespeer.food_delivery_comment_api.service.RestaurantService;
import com.zoespeer.food_delivery_comment_api.vo.*;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.validation.Valid;

import java.util.Map;

@RestController
@RequestMapping("/api/restaurant")
public class RestaurantController {

    @Autowired
    private RestaurantService restaurantService;

    // 接口路径：POST /api/restaurant/list
    @PostMapping("/list")
    public ApiResponse<IPage<RestaurantVO>> getRestaurantList(
            @Valid @RequestBody RestaurantListRequestVO request
    ) {
        IPage<RestaurantVO> result = restaurantService.getRestaurantList(request);
        return ApiResponse.success(result);
    }
    // 新增：获取餐厅详情接口（POST /api/restaurant/detail）
    @PostMapping("/detail")
    public ApiResponse<CanteenDetailVO> getCanteenDetail(
            @Valid @RequestBody CanteenDetailRequestVO request
    ) {
        CanteenDetailVO detail = restaurantService.getCanteenDetail(request);
        return ApiResponse.success(detail);
    }
    // 添加餐厅接口
    @PostMapping("/addCanteen")
    public ApiResponse<Restaurant> addCanteen(
            @Validated @RequestBody AddCanteenVO addCanteenVO
    ) {
        Restaurant restaurant = restaurantService.addCanteen(addCanteenVO);
        return ApiResponse.success(restaurant, "餐厅添加成功");
    }
}